const pages = Object.entries(import.meta.glob('./*/*.{js,jsx,vue}', {eager: true})).map(([key, page]) => {
  const pageKey = key.replace(/^\./, '').replace(/(\/index)?.(jsx?|vue)$/, '');
  if (key.endsWith('.vue')) {
    return {
      key: pageKey,
      config: {
        component: page.default,
      }
    };
  }
  return {
    ...page.default,
    key: pageKey
  };
});

export default pages;

export const pageIndex = pages.reduce((index, page) => {
  index[page.key] = page;
  return index;
}, {});
